import axios from "axios";
import qs from 'qs'
import { message } from "antd";

const http = axios.create({
    baseURL:'/api',
    timeout:60000
});
http.interceptors.request.use(request=>{
    if(Object.prototype.toString.call(request) === '[object Object]'){
        request.data = qs.parse(request.data)
        return request
    }
    
})
http.interceptors.response.use(response=>{
    return response.data;
},reason =>{
    message.error('当前服务繁忙，请您稍后再试～');
    return Promise.reject(reason);
})
export default http;